package edu.hawaii.solardecathlon.page.light;

import java.util.Map;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.link.Link;
import edu.hawaii.solardecathlon.page.BasePage;
import edu.hawaii.solardecathlon.page.images.DesignSet;

/**
 * The lighting page which the user uses to control various lighting functions of the home.
 * 
 * @author Jerry Lau
 */
public class LightingPage extends BasePage {

  /** Support serialization. */
  private static final long serialVersionUID = 1L;

  /**
   * The lighting page for this application.
   */
  public LightingPage() {

    final String lighting_str = "lighting";
    final String cur_room_str = "cur_room";
    
    DesignSet room = new DesignSet();
    Map<String, String> props = getSessionProperties(lighting_str);

    props.put("cur_mode", "Manual");

    add(new Label("top_header", "Select the room you wish to configure."));

    add(new Link<String>("room01Link") {
      /** Support serialization. */
      private static final long serialVersionUID = 1L;
      Map<String, String> props = getSessionProperties(lighting_str);

      /** Upon clicking, choose the room. */
      public void onClick() {
        props.put(cur_room_str, "Room");
        setResponsePage(new LightingPage());
      }
    }
    .add(new Image("room", room.design_02)));
    add(new Link<String>("room02Link") {
      /** Support serialization. */
      private static final long serialVersionUID = 1L;
      Map<String, String> props = getSessionProperties(lighting_str);

      /** Upon clicking, choose the room. */
      public void onClick() {
        props.put(cur_room_str, "Natural Space");
        setResponsePage(new LightingPage());
      }
    }
    .add(new Image("natural_space", room.design_03)));
    add(new Link<String>("room03Link") {
      /** Support serialization. */
      private static final long serialVersionUID = 1L;
      Map<String, String> props = getSessionProperties(lighting_str);

      /** Upon clicking, choose the room. */
      public void onClick() {
        props.put(cur_room_str, "Bathroom");
        setResponsePage(new LightingPage());
      }
    }
    .add(new Image("bathroom", room.design_04)));
    add(new Link<String>("room04Link") {
      /** Support serialization. */
      private static final long serialVersionUID = 1L;
      Map<String, String> props = getSessionProperties(lighting_str);

      /** Upon clicking, choose the room. */
      public void onClick() {
        props.put(cur_room_str, "Kitchen");
        setResponsePage(new LightingPage());
      }
    }
    .add(new Image("kitchen", room.design_05)));
    add(new Link<String>("room05Link") {
      /** Support serialization. */
      private static final long serialVersionUID = 1L;
      Map<String, String> props = getSessionProperties(lighting_str);

      /** Upon clicking, choose the room. */
      public void onClick() {
        props.put(cur_room_str, "Living/Dining/Sleeping");
        setResponsePage(new LightingPage());
      }
    }
    .add(new Image("living", room.design_06)));
    add(new Link<String>("room06Link") {
      /** Support serialization. */
      private static final long serialVersionUID = 1L;
      Map<String, String> props = getSessionProperties(lighting_str);

      /** Upon clicking, choose the room. */
      public void onClick() {
        props.put(cur_room_str, "Entrance");
        setResponsePage(new LightingPage());
      }
    }
    .add(new Image("entrance", room.design_07)));

    ResourceReference presetColors = new ResourceReference(LightingPage.class, "PresetColors.png");
    add(new Image("preset_colors", presetColors));

    ResourceReference purpleSquare = new ResourceReference(LightingPage.class, "purple.png");
    add(new Image("purple", purpleSquare));

    ResourceReference fullBar = new ResourceReference(LightingPage.class, "fullbar.png");
    add(new Image("full_bar", fullBar));

    ResourceReference emptyBar = new ResourceReference(LightingPage.class, "emptybar.png");
    add(new Image("empty_bar", emptyBar));

    add(new Button("mode_save"));
    add(new Button("mode_load"));
    add(new Button("mode_del"));
    add(new Button("lights_on"));
    add(new Button("lights_off"));
    add(new Button("on"));
    add(new Button("off"));

  }
}
